from typing import List
from collections import Counter
from functools import reduce
from math import gcd

最大公约数 = gcd

class Solution:
    def hasGroupsSizeX(self, 牌堆: List[int]) -> bool:
        各牌张数 = Counter(牌堆).values()
        return reduce(最大公约数, 各牌张数) >= 2


s = Solution()
print(s.hasGroupsSizeX([1,2,3,4,4,3,2,1]))
print(s.hasGroupsSizeX([1, 2, 2, 4, 4, 3, 2, 1]))
